# 计科201132叶英杰
import re
import sys
import os
from bs4 import BeautifulSoup
import urllib.request
import xlwt
import sqlite3
def main():
    baseUrl="https://movie.douban.com/top250"
    datalist=get_data(baseUrl)
    # savapath=".\\top250.xls"
    # save_data(savapath)
    html= getUrl(baseUrl)
    print(html)


def save_data(savapath):
    print("save....")

def get_data(baseUrl):
    datalist=[]
    return datalist

def getUrl(url):
    head={}
    head['User-Agent']='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36'
    request=urllib.request.Request(url,headers=head)
    html = ""
    try:
        response=urllib.request.urlopen(request)
        html=response.read().decode("utf-8")
    except urllib.error.URLError as e:
        if hasattr(e,"code"):
            print(e.code)
        if hasattr(e,"reason"):
            print(e.reason)
    return html

if __name__ == '__main__':
    main()